<!--create by bjy 2019-04-15 -->
<template class="template">
    <div class="activityRelease">
      <div style="background: #fff; padding-bottom: 10px;">
        <div class="activityRelease-left-title">
          <h2>{{pageTitle}}</h2>
        </div>
	      <div class="activity-title-line"></div>
        <div class="button-input">
          <div class="button-arr">
            <el-button type="primary" class='activity-button' plain @click="dialogAddActivityFormVisible = true">添加活动</el-button>
            <el-button type="primary" class='activity-button' plain @click="reviewReleaseActivity">审核发布</el-button>
            <el-button type="primary" class='activity-button' plain @click="cancelActivityPublished">取消活动</el-button>
          </div>
	  	<div class="input-search">
          <el-input style="width:20%;" v-model="seachVue" placeholder="活动名称搜索" @input="changeInputByActivityName">
            <i slot="prefix" class="el-input__icon el-icon-search"></i>
          </el-input>
        </div>
      </div>
        <!--数据列表-->
        <div class="activity-table">
          <ActivityListSub :tableDataList="tableData" @changeData="changeTableData"></ActivityListSub>
        </div>
        <!-- 分页 -->
        <div style="width: 100%;text-align: center; margin: 5px auto">
          <el-pagination
            background
            layout="prev, pager, next"
            :page-size="pageSize"
            :total="total"
            @current-change="handleCurrentChange">
          </el-pagination>
        </div>
        <!-- 添加活动 -->
        <div>
          <el-dialog title="添加活动" :visible.sync="dialogAddActivityFormVisible" :before-close="closeFormRestAddActivity">
            <NavBaiduMap :centerMap="centerMap" :zoomSize="zoomSize" :openCloseStatus="dialogAddActivityFormVisible" @getPoint="getMapClick"></NavBaiduMap>
            <el-form :model="form"  ref="form" >
              <tr>
                <td colspan="2">
                  <el-form-item label="活动地点" :label-width="formLabelWidth" prop="address">
                    <el-input v-model="form.activitysitename" autocomplete="off"></el-input>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td colspan="2">
                  <el-form-item label="活动名称" :label-width="formLabelWidth" prop="activitytitle">
                    <el-input v-model="form.activitytitle" autocomplete="off"></el-input>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td>
                  <el-form-item label="签到开始时间" :label-width="formLabelWidth" prop="activitysignstarttime">
                    <el-date-picker
                      v-model="form.activitysignstarttime" type="datetime" placeholder="选择日期时间" default-time="12:00:00">
                    </el-date-picker>
                  </el-form-item>
                </td>
                <td>
                  <el-form-item label="签到截止时间" :label-width="formLabelWidth" prop="activitysignendtime">
                    <el-date-picker v-model="form.activitysignendtime"
                      type="datetime" placeholder="选择日期时间" default-time="12:00:00">
                    </el-date-picker>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td>
                  <el-form-item label="活动开始时间" :label-width="formLabelWidth" prop="activitystarttime">
                    <el-date-picker
                      v-model="form.activitystarttime"
                      type="datetime"
                      placeholder="选择日期时间"
                      default-time="12:00:00">
                    </el-date-picker>
                  </el-form-item>
                </td>
                <td>
                  <el-form-item label="活动截止时间" :label-width="formLabelWidth" prop="activityendtime">
                    <el-date-picker
                      v-model="form.activityendtime"
                      type="datetime"
                      placeholder="选择日期时间"
                      default-time="12:00:00">
                    </el-date-picker>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td>
                  <el-form-item label="所属支部/党委" :label-width="formLabelWidth" prop="organizationid">
                    <el-select v-model="form.organizationid" placeholder="请选择活动支部/党委">
                      <el-option label="中兴社区" value="1"></el-option>
                      <el-option label="光辉村支部" value="2"></el-option>
                    </el-select>
                  </el-form-item>
                </td>
                <td>
                  <el-form-item label="活动类型" :label-width="formLabelWidth" prop="activityid">
                    <el-select v-model="form.activityid" placeholder="请选择活动类型">
                      <el-option
                        v-for="item in activityTypeArr"
                        :key="item.id"
                        :label="item.categoryname"
                        :value="item.id"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td>
                  <el-form-item label="活动积分" :label-width="formLabelWidth" prop="integral">
                    <el-input v-model="form.activityintegral" autocomplete="off" type="number" style="width: 120px" :disabled="true"></el-input>
                  </el-form-item>
                </td>
                <td>
                  <el-form-item label="选择人员" :label-width="formLabelWidth">
                    <el-button type="primary" class='activity-button' plain @click="selectAddActivityPeople">选择人员</el-button>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td colspan="2">
                  <UEditor :config=ueConfig ref="addUeditor" id="addUeditor"></UEditor>
                </td>
              </tr>
              </el-form>
              <div slot="footer" class="dialog-footer">
                <el-button @click="closeFormRestAddActivity()">取 消</el-button>
                <el-button type="primary" @click="formSubmintAddActivity()">确 定</el-button>
              </div>
              <!-- 内部对话窗 选择人员 -->
              <el-dialog
                width="40%"
                title="选择人员"
                :visible.sync="innerAddActivityVisible"
                append-to-body>
                <div style="text-align: center">
                  <el-transfer
                    v-model="changeAddActivityPeopleValue" style="text-align: left; display: inline-block" filterable
                    :props="{key: 'userId',label: 'userName'}" @change="handleChangePeople"
                    :titles="['组织人员', '参与人员']" :button-texts="['取消选择', '选择参加']"
                    :data="changeAddActivityPeopleData">
                  </el-transfer>
                </div>
                <div slot="footer" class="dialog-footer">
                  <el-button @click="closeFormRestAddActivitySub()">取 消</el-button>
                  <el-button type="primary" @click="formSubmintAddActivitySub()">确 定</el-button>
                </div>
              </el-dialog>
            </el-dialog>
        </div>
        <!-- 审核发布 -->
        <div>
          <el-dialog title="审核发布" :visible.sync="dialogReleaseActivityVisible" :before-close="closeFormRestRelease">
            <NavBaiduMap :centerMap="releaseActivityCenterMap" :zoomSize="zoomSize" :openCloseStatus="dialogReleaseActivityVisible" @getPoint="getMapClickUpdate"></NavBaiduMap>
            <el-form :model="updateForm"  ref="tableDataChecked" >
              <tr>
                <td colspan="2">
                  <el-form-item label="活动地点" :label-width="formLabelWidth" prop="address">
                    <el-input v-model="updateForm.activitysitename" autocomplete="off"></el-input>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td colspan="2">
                  <el-form-item label="活动名称" :label-width="formLabelWidth" prop="activityTitle">
                    <el-input v-model="updateForm.activitytitle" autocomplete="off"></el-input>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td>
                  <el-form-item label="签到开始时间" :label-width="formLabelWidth" prop="signStartTime">
                    <el-date-picker
                      v-model="updateForm.activitysignstarttime"
                      type="datetime"
                      placeholder="选择日期时间"
                      default-time="12:00:00">
                    </el-date-picker>
                  </el-form-item>
                </td>
                <td>
                  <el-form-item label="签到截止时间" :label-width="formLabelWidth" prop="signEndTime">
                    <el-date-picker
                      v-model="updateForm.activitysignendtime"
                      type="datetime"
                      placeholder="选择日期时间"
                      default-time="12:00:00">
                    </el-date-picker>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td>
                  <el-form-item label="活动开始时间" :label-width="formLabelWidth" prop="activityStartTime">
                    <el-date-picker
                      v-model="updateForm.activitystarttime"
                      type="datetime"
                      placeholder="选择日期时间"
                      default-time="12:00:00">
                    </el-date-picker>
                  </el-form-item>
                </td>
                <td>
                  <el-form-item label="活动截止时间" :label-width="formLabelWidth" prop="activityEndTime">
                    <el-date-picker
                      v-model="updateForm.activityendtime"
                      type="datetime"
                      placeholder="选择日期时间"
                      default-time="12:00:00">
                    </el-date-picker>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td>
                  <el-form-item label="所属支部/党委" :label-width="formLabelWidth" prop="organization">
                    <el-select v-model="updateForm.organizationid" placeholder="请选择活动支部/党委">
                      <el-option label="中兴社区" value="中兴社区"></el-option>
                      <el-option label="光辉村支部" value="光辉村支部"></el-option>
                    </el-select>
                  </el-form-item>
                </td>
                <td>
                  <el-form-item label="活动类型" :label-width="formLabelWidth" prop="activityType">
                    <el-select v-model="updateForm.activityid" placeholder="请选择活动类型">
                      <el-option
                        v-for="item in activityTypeArr"
                        :key="item.id"
                        :label="item.categoryname"
                        :value="item.id"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td>
                  <el-form-item label="活动积分" :label-width="formLabelWidth" prop="integral">
                    <el-input v-model="updateForm.categoryintegral" autocomplete="off" type="number" style="width: 120px"></el-input>
                  </el-form-item>
                </td>
                <td>
                  <el-form-item label="选择人员" :label-width="formLabelWidth">
                    <el-button type="primary" class='activity-button' plain @click="changeReleaseActivityPeople()">选择人员</el-button>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td colspan="2">
                  <UEditor :config=ueConfig ref="releaseUeditor" id="releaseUeditor"></UEditor>
                </td>
              </tr>
            </el-form>
            <div slot="footer" class="dialog-footer">
              <el-button @click="closeFormRestRelease()">取 消</el-button>
              <el-button type="primary" @click="formSubmintRestRelease('from')">确 定</el-button>
            </div>
            <!-- 内部对话窗 选择人员 -->
            <el-dialog
              width="40%"
              title="选择人员"
              :visible.sync="innerReleaseActivityVisible"
              append-to-body>
              <div style="text-align: center">
                <el-transfer
                  v-model="changeReleaseActivityPeopleValue" style="text-align: left; display: inline-block" filterable
                  :props="{key: 'userId',label: 'userName'}" @change="handleChangePeople"
                  :titles="['组织人员', '参与人员']" :button-texts="['取消选择', '选择参加']"
                  :data="changeReleaseActivityPeopleData">
                </el-transfer>
              </div>
              <div slot="footer" class="dialog-footer">
                <el-button @click="closeFormRestRelease()">取 消</el-button>
                <el-button type="primary" @click="formSubmintRestRelease('from')">确 定</el-button>
              </div>
              <!-- 内部对话窗 选择人员 -->
              <el-dialog
                width="40%"
                title="选择人员"
                :visible.sync="innerReleaseActivityVisible"
                append-to-body>
                <div style="text-align: center">
                  <el-transfer
                    v-model="changeReleaseActivityPeopleValue" style="text-align: left; display: inline-block" filterable
                    :props="{key: 'userId',label: 'userName'}" @change="handleChangePeople"
                    :titles="['组织人员', '参与人员']" :button-texts="['取消选择', '选择参加']"
                    :data="changeReleaseActivityPeopleData">
                  </el-transfer>
                </div>
                <div slot="footer" class="dialog-footer">
                  <el-button @click="closeFormRestRestReleaseSub()">取 消</el-button>
                  <el-button type="primary" @click="formSubmintRestReleaseSub()">确 定</el-button>
                </div>
              </el-dialog>
            </el-dialog>
          </el-dialog>
        </div>
      </div>
    </div>
</template>

<script>
  // Js文件引入
  import Utils from '../../../../Js/utils.js'

  import ElButton from "../../../../../node_modules/element-ui/packages/button/src/button";
//  富文本编辑器
  import UEditor from "../../NavUeditor/NavUeditor.vue"
//  活动list列表展示页面
  import ActivityListSub from "../ActivityReleased/ActivityListSub.vue"
//  百度地图
  import NavBaiduMap from "../../NavBaiduMap/NavBaiduMap.vue"
  import ElInput from "../../../../../node_modules/element-ui/packages/input/src/input";

    //  此处导入组件,格式,例如:import xxx名称 from "路径"
    export default{
        // 这里是name,记得填写
        name: 'activityRelease',
        //  数据定义
        data () {
//            人员选择常量
          const generateData = _ => {
            const data = [];
            for (let i = 0; i <= 15; i++) {
              data.push({
                userId: i,
                userName: `备选项 ${ i }`,
              });
            }
            return data;
          };
            return {
//            当前页面
              currentPage: 1,
//            每页显示几条
              pageSize: 10,
//            总条目数
              total: 0,
//              页面标题
              pageTitle:'活动管理-活动发布',
//              地图相关
              centerMap:{lng:120.151945,lat:30.526979},// 中心坐标 雷甸镇人民政府
//              审核修改的地图坐标
              releaseActivityCenterMap:null,
              zoomSize:17,// 缩放级别
              seachVue:null,// 搜索展示词
//              列表数据
              tableData: [],
//              表单选中数据绑定
              tableDataChecked:null,
              // 活动类型
              activityTypeArr:null,
//              新增页面的弹窗
              dialogAddActivityFormVisible: false,
//              新增页面的选择人员窗口
              innerAddActivityVisible:false,
//              审核发布的选择人员窗口
              innerReleaseActivityVisible:false,
//              审核发布页面弹窗
              dialogReleaseActivityVisible:false,
//              审核发布
              dialogVisible:false,
//              富文本编辑器相关
              ueConfig: {
                // 可以在此处定义工具栏的内容
                toolbars: [[
                  'fullscreen',  '|', 'undo', 'redo', '|',
                  'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
                  'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
                  'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
                  'directionalityltr', 'directionalityrtl', 'indent', '|',
                  'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
                  'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
                  'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment', 'insertframe', 'pagebreak', 'template', 'background', '|',
                  'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|',
                  'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
                  'print', 'preview', 'searchreplace', 'help', 'drafts'
                ]],
                zIndex:3000,
                elementPathEnabled : false,// 隐藏下方的元素路径
                autoHeightEnabled: false,
                autoFloatEnabled: true,
                initialContent:'请输入内容',   //初始化编辑器的内容,也可以通过textarea/script给值，看官网例子
                autoClearinitialContent:true, //是否自动清除编辑器初始内容，注意：如果focus属性设置为true,这个也为真，那么编辑器一上来就会触发导致初始化的内容看不到了
                initialFrameWidth: null,
                initialFrameHeight: 300,
                BaseUrl: '',
                UEDITOR_HOME_URL: 'static/ueditor/'
              },
//              新增页面数据
              form: {
                activitytitle: null,// 活动名称
                activitycontent:null,// 活动内容
                activitysitename: null,// 活动地点名称
                activitysignstarttime:null,//允许签到的最早时间
                activitysignendtime:null,// 允许签到的最晚时间
                activitystarttime:null,// 活动开始时间
                activityendtime:null,// 活动结束时间
                activityid:null,// 活动类型id
                activitydigest:null,// 活动摘要
                activityimg:null,// 活动展示图
                activitynumber:null,// 活动人数
                organizationid:1,// 组织Id
                activityintegral:0,// 活动积分
                activitylongitude:0,// 经度
                activitylatitude:0// 纬度
              },
              updateForm:{},
              formLabelWidth: '120px',
              // 定时器
              setTimeout:null,
//              人员选择数据
              changeAddActivityPeopleData: generateData(),
              changeAddActivityPeopleValue: [1],
//              人员修改数据
              changeReleaseActivityPeopleData:generateData(),
              changeReleaseActivityPeopleValue: [1],
            }
        },
        created() {
          let _this = this;
            // 获取活动类型
          this.$http.post(
              this.$BASE_URL+'activitycategory/findall',
                {},{emulateJSON:false}).then(function(res){
                _this.activityTypeArr = res.data
          },function (res) {
            console.error(res.data.resMessages)
          });
          // 查询活动信息
          this.selectActivityListByPageLimit(1)
        },
        // 页面方法
        methods: {
//            活动名称查询
          changeInputByActivityName(e){
              console.log(e)
          },
            // 分页查询,根据userid
          selectActivityListByPageLimit(pageNum){
//            console.log(pageNum);
            let _this = this;
            this.$http.post(
              this.$BASE_URL+'activity/selectbyuserid',
              {pageNum:pageNum,pageSize:this.pageSize},{emulateJSON:false}
            ).then(function (res) {
                console.log(res);
                let selectPageList = res.data.list;
              for(let i = 0; i < selectPageList.length; i++){
                if(selectPageList[i].activityflag === 0){
                  selectPageList[i]['activitystatus'] = '待审核'
                }else if(selectPageList[i].activityflag === 1){
                  selectPageList[i]['activitystatus'] = '审核通过'
                }
              }
                _this.total = res.data.total;
              _this.tableData = selectPageList
            },function (res) {

            })
          },
//            新增地图点击事件,获得经纬度,详细地址
          getMapClick(e){
              this.form.activitylongitude = e.lng
              this.form.activitylatitude = e.lat
              this.form.activitysitename = e.site
          },
          getMapClickUpdate(e){
            this.updateForm.activitylongitude = e.lng;
            this.updateForm.activitylatitude = e.lat;
            this.updateForm.activitysitename = e.site
          },
//          列表选中的数据
          changeTableData(e){
            this.tableDataChecked = e
          },
//          审核发布按钮
          reviewReleaseActivity(){
              let _this = this;
            if(!this.tableDataChecked){// 没有选中数据
              this.$notify.error({
                title: '操作错误',
                message: '请先选择一条数据,再进行审核发布'
              });
              return;
            }
            this.$http.post(
                this.$BASE_URL+'activity/selectshowbyid',// 参数: 活动id String
              {id:this.tableDataChecked.id},{emulateJSON:false}
            ).then( res =>{
                if(res.data.code === 200){
                  let resData = res.data.output;
                  _this.releaseActivityCenterMap = {lng:resData.activitylongitude,lat:resData.activitylatitude};
                    // 向富文本编辑器存值
                  _this.updateForm = resData;
                  _this.dialogReleaseActivityVisible = true;

                  _this.setTimeout = setTimeout(()=>{// 富文本初始化赋值
                    _this.$refs.releaseUeditor.setUEContent(resData.activitycontent);
                    clearTimeout(_this.setTimeout)
                  },2000);
                }else {
                  _this.$message({
                    message: res.data.resMessage,
                    type: 'error'
                  });
                }
            },res =>{
              console.error(res.data.resMessages)
            })
          },
//          取消发布按钮
          cancelActivityPublished(){
            let _this = this;
            if(!this.tableDataChecked){// 没有选中数据
              this.$notify.error({
                title: '操作错误',
                message: '请先选择一条数据,再进行取消活动'
              });
              return;
            }
//            询问框
            this.$confirm('此操作将让该活动恢复待审核状态,是否继续?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(() => {// 点击确定 发起http请求
              // 请求参数
              let activityModel = {id:this.tableDataChecked.id,activityflag:0};
              this.$http.post(// 根据活动id,修改活动状态,取消活动
                this.$BASE_URL+'activity/updateflag',
                activityModel,{emulateJSON:true}).then(function(res){
                let resCode = res.data.code;
                if (resCode === 200){
                  _this.$message({
                    type: 'success',
                    message: res.data.resMessage
                  });
                  // 重新刷新页面
                  _this.selectActivityListByPageLimit(_this.currentPage,1)
                }else{
                  _this.$message({
                    message:res.data.resMessage,
                    type:'error'
                  })
                }
              },function(res){
                console.log(res.status);
              });
            }).catch(() => {// 点击取消

            });
          },
//            进行分页的数据
          handleCurrentChange(e){
              this.selectActivityListByPageLimit(e,1)
          },
//          新增活动选择参加活动人员 当前值、数据移动的方向（'left' / 'right'）、发生移动的数据 key 数组
          handleChangePeople(value, direction, movedKeys){
//            console.log(value, direction, movedKeys);
          },
          // 新增活动表单提交
          formSubmintAddActivity(){
            let _this = this;
              // 获取富文本中的信息
            let contentHtml = this.$refs.addUeditor.getUEContent();// html格式
            let content = this.$refs.addUeditor.getContentTxt();//纯文本形式
            this.form.activityImg = this.getFirstImage(contentHtml);
            this.form.activitynumber = this.changeAddActivityPeopleValue.length;
            this.form.activitycontent = contentHtml;
            this.form.activitydigest = content;
            let activityAdd = this.form;
            if(!activityAdd.activitystarttime||!activityAdd.activityendtime ||
              !activityAdd.activitysignstarttime||!activityAdd.activitysignendtime){
              this.$message({
                message: '警告! 请先将 时间 填写完整, 再进行活动添加',
                type: 'error'
              });
              return;
            }
            // 日期格式转换 yyyy-MM-dd hh:mm:ss
            activityAdd.activitystarttime = Utils.formatTime(activityAdd.activitystarttime);
            activityAdd.activityendtime = Utils.formatTime(activityAdd.activityendtime);
            activityAdd.activitysignstarttime = Utils.formatTime(activityAdd.activitysignstarttime);
            activityAdd.activitysignendtime = Utils.formatTime(activityAdd.activitysignendtime);
            this.$http.post(
              this.$BASE_URL+'activity/addactivity',
              {activityModel:activityAdd,array:this.changeAddActivityPeopleValue },{emulateJSON:true}).then(function(res){
                  if(res.data.code === 200){
                    _this.$message({
                      message: '活动添加成功',
                      type: 'success'
                    });
                    _this.$refs.form.resetFields();
                    _this.$refs.addUeditor.setUEContent('<p>请输入内容</p>');// 放值
                    _this.dialogAddActivityFormVisible = false;
                    _this.selectActivityListByPageLimit(1);
                    _this.currentPage = 1
                  }else{
                    _this.$message({
                      message: res.data.resMessage,
                      type: 'error'
                    });
                  }
            },function (res) {
              console.error(res.msg)
            });
            // 恢复富文本初始化状态
            this.$refs.addUeditor.setUEContent('<p>请输入内容</p>');
          },
          // 新增活动表单关闭
          closeFormRestAddActivity(done){
            this.$confirm('确认是否关闭？页面上的数据将不会被保留')
              .then(_ => {
                this.$refs.form.resetFields();
                this.$refs.addUeditor.setUEContent('<p>请输入内容</p>');
                this.dialogAddActivityFormVisible = false;
                done();
              })
              .catch(_ => {});
          },
          // 新增活动内置页面选择人员弹窗
          selectAddActivityPeople(){
            this.innerAddActivityVisible = true
          },
          // 新增表单中内置弹窗选择人员关闭
          closeFormRestAddActivitySub(done){
            this.$confirm('确认是否关闭？')
              .then(_ => {
                this.innerAddActivityVisible = false
                done();
              })
              .catch(_ => {});
          },
          // 新增表单中内置弹窗选择人员确定
          formSubmintAddActivitySub(){
            let peopleNum = this.changeAddActivityPeopleValue;
            for(let i = 0 ;i < peopleNum.length;i++){
            }
            this.innerAddActivityVisible = false
          },
//          审核发布表单提交
          formSubmintRestRelease(){
              let _this = this;
            let activityUpdate = this.updateForm;
            // 获取富文本中的信息
            let contentHtml = this.$refs.releaseUeditor.getUEContent();// html格式
            let content = this.$refs.releaseUeditor.getContentTxt();//纯文本形式
            console.log(contentHtml);
            activityUpdate.activityImg = this.getFirstImage(contentHtml);
            activityUpdate.activitynumber = this.changeReleaseActivityPeopleValue.length;
            activityUpdate.activitycontent = contentHtml;
            activityUpdate.activitydigest = content;

            if(!activityUpdate.activitystarttime||!activityUpdate.activityendtime ||
              !activityUpdate.activitysignstarttime||!activityUpdate.activitysignendtime){
              this.$message({
                message: '警告! 请先将 时间 填写完整, 再进行活动添加',
                type: 'error'
              });
              return;
            }
//            // 日期格式转换 yyyy-MM-dd hh:mm:ss
            activityUpdate.activitystarttime = Utils.formatTime(activityUpdate.activitystarttime);
            activityUpdate.activityendtime = Utils.formatTime(activityUpdate.activityendtime);
            activityUpdate.activitysignstarttime = Utils.formatTime(activityUpdate.activitysignstarttime);
            activityUpdate.activitysignendtime = Utils.formatTime(activityUpdate.activitysignendtime);
            this.$http.post(
                this.$BASE_URL+'activity/updateactivity',
              {activityModel:activityUpdate,array:this.changeReleaseActivityPeopleValue },{emulateJSON:true}
            ).then(res => {
              let resCode = res.data.code;
              if(resCode===200){
                _this.$message({
                  message: '编辑发布成功',
                  type: 'success'
                });
                _this.dialogReleaseActivityVisible = false;
                _this.selectActivityListByPageLimit(1,1);
                _this.currentPage = 1
              }else{
                _this.$message({
                  message: '错误',
                  type: 'error'
                });
              }
            },res =>{

            })
          },
//          审核发布表单关闭
          closeFormRestRelease(done){
            this.$confirm('确认是否关闭？页面上的数据将不会被保留')
              .then(_ => {
                this.$refs.tableDataChecked.resetFields();
                this.dialogReleaseActivityVisible = false;
                done();
              })
              .catch(_ => {});
          },
          // 审核发布中的选择人员事件触发
          changeReleaseActivityPeople(){
              let _this = this;
              this.$http.post(
                  this.$BASE_URL+'activity/selectalljoin',
                {id:this.updateForm.id},{emulateJSON:false}
              ).then(res => {
                  console.log(res)
              },res => {
                  console.error(res)
              });
            this.innerReleaseActivityVisible = true
          },
          // 审核发布表单中内置弹窗选择人员关闭
          closeFormRestRestReleaseSub(done){
            this.$confirm('确认是否关闭？')
              .then(_ => {
                this.innerReleaseActivityVisible = false;
                done();
              })
              .catch(_ => {});
          },
          // 审核发布表单中内置弹窗选择人员确定
          formSubmintRestReleaseSub(){
            this.innerReleaseActivityVisible = false;
          },
          // 获取第一张图片
          getFirstImage(contentHtml){
            let firstImage;
            let imgReg = /<img.*?(?:>|\/>)/gi;
            let srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i;
            let arr = contentHtml.match(imgReg);  // arr 为包含所有img标签的数组
            if(!arr){// 该文本字段中无图片
              arr = [];
              return firstImage = ''
            }
            for (let i = 0; i < arr.length; i++) {
              let src = arr[i].match(srcReg);
              //获取图片地址
              let fdStart = src[1].indexOf("/");
              if (fdStart === 0) {
                firstImage = "http://192.168.1.104:8081"+src[1]
                //表示src[1]是以/开头；
              } else if (fdStart === -1) {
                firstImage = src[1]
                //表示src[1]不是以/开头
              }
            }
            return firstImage;
          },
        },
        // 计算属性
        computed: {},
        // 侦听器
        watch: {
          'form.activityid'(res){
            let activityTypeArr = this.activityTypeArr;
            let categoryintegral;
            for(let i = 0;i<activityTypeArr.length;i++){
              if(activityTypeArr[i].id === res){
                categoryintegral = activityTypeArr[i].categoryintegral;
                break;
              }
            }
            this.form.activityintegral = categoryintegral
          },
          'updateForm.activityid'(res){
              console.log(res)
            let activityTypeArr = this.activityTypeArr;
            let categoryintegral ;
            for(let i = 0;i<activityTypeArr.length;i++){
              if(activityTypeArr[i].id === res){
                categoryintegral = activityTypeArr[i].categoryintegral;
                break;
              }
            }
            this.updateForm.categoryintegral = categoryintegral
          },
        },
        // 依赖注入
        components: {
          ElInput,
          ElButton,
          UEditor,
          ActivityListSub,
          NavBaiduMap
        }
    }
</script>

<!-- 本地样式 -->
<style scoped>
  .activityRelease{
    width: 100%;
    height: 100%;
    background-color: #fff;
  }
  .activityRelease-left-title{
    text-align: left;
    padding: 10PX 20PX;
  }
  .activity-title-line{
    height:1px;
    width: 98%;
    margin: auto 1%;
    background-color: #ddd;
  }
  .activity-table{
    text-align: center;
    width:100%;
    display: flex;;
    justify-content: center;
    align-content: center;
  }
  .button-input{
    display: flex;
  }
  .input-search{
    width: 60%;
    text-align: right;
    margin: 10px 0;
  }

  .button-arr{
    margin: 10px 0 10px 30px;
  }
  .activity-button{
    margin: 0 20px;
  }
</style>
